home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / SYMBMATH.H15 < prev    next >
Text File  |  1993-11-07  |  976b  |  37 lines

  1.         3.3.5  Loop 
  2.     You can use two kinds of loops in SymbMath, fixed length
  3. loops controlled by do() and variable-length loops controlled by
  4. repeat(). The do() loop is similar to the FOR loop in BASIC language.
  5.     The control variable in the do() loops is not limited to
  6. integer values.  You can say:
  7.  
  8.         do(f:=f+1, x from xmin to xmax step dx)
  9.  
  10. It is similar to
  11.         FOR x := xmin TO xmax STEP dx
  12.         f:=f+1
  13.         NEXT x
  14. where xmin, xmax, and dx are real values.  If STEP dx is omitted, it
  15. defaults to 1.
  16.  
  17.     e.g.
  18. IN:  x:=1
  19. OUT: x := 1
  20. IN:  do(x:=x+1, j from 1 to 5 step 1)
  21. OUT: x := 5
  22.  
  23.  
  24.       The conditional loops are probably more useful than the do()
  25. loops if a number of iteration is unknown. It is
  26.         repeat(y until test)
  27.         repeat(y, test)
  28. The word (until) can be replaced by comma ,.
  29. The repeat() repeats to evaluate f until the test is true (i.e. the
  30. result of the test is 1).
  31.     Example.
  32.  
  33. IN:  x:=1
  34. OUT: x := 1
  35. IN:  repeat(x:=x+1 until x>5)
  36. OUT: x := 6
  37.